<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ProfileManagement.ascx.cs" Inherits="admin_webparts_Common_ProfileManagement" %>
<%@ Import Namespace="NTTHAO.CommonWeb" %> 

<script type="text/javascript">
NTTHAO.namespace('page');

NTTHAO.page.langText = [];
NTTHAO.page.langText['BLANK_PASSWORD'] = '<%=LanguageUtility.GetLanguageText("BLANK_PASSWORD", Session)%>';
NTTHAO.page.langText['INVALID_PASSWORD'] = '<%=LanguageUtility.GetLanguageText("INVALID_PASSWORD", Session)%>';
NTTHAO.page.langText['PASSWORD_NOT_MATCH'] = '<%=LanguageUtility.GetLanguageText("PASSWORD_NOT_MATCH", Session)%>';
NTTHAO.page.langText['ERROR_MESSAGE'] = '<%=this._ErrorMessage %>';

function validateSubmit() { 
    var txtChangePass_New = document.getElementById("<%=txtPassword.ClientID %>");
    var txtChangePass_Retype = document.getElementById("<%=txtRetypePassword.ClientID %>");
    
    var passwordRequired = true;
    
    var errorMessage = "";
    
    if(passwordRequired) {
        errorMessage = CheckFieldString("noblank", txtChangePass_New, NTTHAO.page.langText['BLANK_PASSWORD']);
        if(errorMessage != "")
        {
            alert(errorMessage);
            txtChangePass_New.select();
            txtChangePass_New.focus();
            return false;
        }
    }
    
    if(passwordRequired || txtChangePass_New.value.length > 0 || txtChangePass_Retype.value.length > 0) {
        errorMessage = CheckFieldString("alphanum", txtChangePass_New, NTTHAO.page.langText['INVALID_PASSWORD']);
        if(errorMessage != "")
        {
            alert(errorMessage);
            txtChangePass_New.select();
            txtChangePass_New.focus();
            return false;
        }
        
        if (txtChangePass_New.value != txtChangePass_Retype.value) {
            alert(NTTHAO.page.langText['PASSWORD_NOT_MATCH']);
            txtChangePass_New.select();
            txtChangePass_New.focus();
            return false;
        }
        
        if (txtChangePass_New.value.length < 5 || txtChangePass_New.value.length > 30) {
            alert(NTTHAO.page.langText['INVALID_PASSWORD']);
            txtChangePass_New.select();
            txtChangePass_New.focus();
            return false;
        }
    }
    return true;
}
function doSubmit(  ) {
    if(!validateSubmit()) {
        return false;
    }
    
    var txtChangePass_New = document.getElementById("<%=txtPassword.ClientID %>");
    var txtChangePass_Retype = document.getElementById("<%=txtRetypePassword.ClientID %>");
    var encryptedPassword = document.getElementById("<%=encryptedPassword.ClientID %>");
    if(txtChangePass_New.value.length > 0) {
        var md5Password = hex_md5(txtChangePass_New.value);
        encryptedPassword.value = md5Password;
    } else {
        encryptedPassword.value = "";
    }
    txtChangePass_New.value = "";
    txtChangePass_Retype.value = "";
    
    return true;
}
</script>
<%if (this._EditingUser != null && this._EditingUser.UserName.Equals("admin", StringComparison.OrdinalIgnoreCase) && !Context.User.Identity.Name.Equals("admin"))
  { %>
 <div class="tip"><%=LanguageUtility.GetLanguageText("NOT_AUTHORISE", Session)%> <a href="#" onclick="javascript: history.back(1); return false;"><%=LanguageUtility.GetLanguageText("CLICK_RETURN", Session)%></a></div>
<%} else { %>
<form id="NewUser" runat="server" onsubmit="return doSubmit();">
<input type="hidden" id="userID" name="userID" value="" runat="server"/>
<input type="hidden" id="encryptedPassword" name="encryptedPassword" value="" runat="server"/>
<div class="tip">
    <h1><%=LanguageUtility.GetLanguageText("CHANGE_PASSWORD", Session)%></h1>
</div>
<table cellspacing="0" cellpadding="0" border="1" class="grid" style="margin-bottom: 10px;">
    <tr class="even">
        <td align="right" style="height: 34px">
            <%=LanguageUtility.GetLanguageText("PASSWORD", Session)%>:</td>
        <td style="height: 34px">
            <asp:TextBox ID="txtPassword" runat="server" Width="200px" TextMode="Password"></asp:TextBox>&nbsp;<div style="color: mediumblue; background-color: moccasin; padding: 3px 10px 3px 10px; display: inline;"><%=LanguageUtility.GetLanguageText("PASSWORD_HIT", Session)%></div>
            </td>
    </tr>
    <tr class="odd">
        <td align="right">
            <%=LanguageUtility.GetLanguageText("RETYPE_PASSWORD", Session)%>:</td>
        <td>
            <asp:TextBox ID="txtRetypePassword" runat="server" TextMode="Password" Width="200px"></asp:TextBox></td>
    </tr>
</table>
<p align="left">
    <span id="spSave" class="yui-button yui-link-button yuibtn yuibtn-icon btnsave"><span class="first-child"><asp:Button ID="btnSave" runat="server" OnClick="btnSave_Click" Text="Save" /></span></span>
    <span id="spCancel1" class="yui-button yui-link-button yuibtn yuibtn-icon btncancel"><span class="first-child"><input id="btnCancel1" type="button" value="<%=LanguageUtility.GetLanguageText("CANCEL", Session)%>" onclick="javscript: location.href='?';" /></span></span>
</p>
</form>
<style type="text/css">
    #spCancel1, #spSave {font-size:1.1em; font-weight: bold; }
    #spCancel1 button, #spSave button { font-family: Verdana,Arial,Helvetica,sans-serif; font-weight: bold; }
</style>
<script type="text/javascript"> 
YAHOO.util.Event.onContentReady("spCancel1", function () {
    var spCancel1 = new YAHOO.widget.Button("spCancel1");
    spCancel1.on("click", function () {location.href='?';}); 
});
YAHOO.util.Event.onContentReady("spSave", function () {
    var spSave = new YAHOO.widget.Button("spSave");
});
YAHOO.util.Event.onDOMReady(function() {
    document.getElementById("<%=txtPassword.ClientID %>").focus();
    document.getElementById("<%=txtPassword.ClientID %>").value = "";
});
if(NTTHAO.page.langText['ERROR_MESSAGE'] != '') {
    YAHOO.util.Event.onDOMReady(function() {
        alert(NTTHAO.page.langText['ERROR_MESSAGE']);
    });
}
</script>
<%} %>